<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.min.css" />
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <link class="theme" rel="stylesheet" type="text/css" href="./css/color/blue.css" />
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <script type="text/javascript" src="./script/echo.min.js"></script>

</head>

<body>
    <div class="head">
        <div class="head-s">
            <span><div id='topbar'>市管领导干部信息查询系统--自定义查询</div></span>
            <div class="head-l"><i class="fa fa-caret-left" onclick="closeWin()"></i></div>
            <!-- <div class="head-r"><i class="fa fa-user"></i></div> -->
        </div>
    </div>
    <!-- <header class="aui-bar aui-bar-nav header">
        <a class="aui-pull-left">
            <span class="aui-iconfont aui-icon-left" onclick="closeWin()"></span>
        </a>
        <div class="aui-title" id='topbar'><span>市管领导干部信息查询系统条件查询</span></div>
        <a class="aui-pull-right aui-btn">
            <span class="fa fa-user-circle-o"></span>
        </a>
    </header> -->
    <div class="header-d"></div>

    <!-- 分类 -->
    <!-- <div class="list-t">
        <img src="images/cover_logo.png">
        <span>中共佳木斯市委组织部</span>
    </div> -->
    <div style="padding:20px 20px 0;" id='count'>符合条件记录数(0)条</div>

    <div id="list">
    </div>
    <script type='text/template' id='template'>
        <div class="classify-img">
            <ul>
                {{~it :value:index}} {{? value==0}}
                <h2 class="classify-no"></h2> {{??}}
                <li onclick="click_in({{=value.userID}})">
                    <!-- <img src="file:///storage/emulated/0/ader/java/{{=value.userID}}.jv"> -->
                    <img src="file:///storage/emulated/0/ader/java/{{=value.userID}}.jv"  data-echo="file:///storage/emulated/0/ader/java/{{=value.userID}}.jv">
                    <dl>
                        <!-- <dt>file:///storage/emulated/0/ader/java/{{=value.userID}}.jv</dt> -->
                        <dt>{{=value.I01}}</dt>

                        <dd>{{=value.I16}}</dd>
                    </dl>
                </li>
                {{?}} {{~}}
            </ul>
        </div>
    </script>

</body>
<script type="text/javascript" src="./script/api.js"></script>

</html>
<script>
function echoInit() {
        echo.init({
                offset : 20000,
                throttle : 0 //设置图片延迟加载的时间
        });
}
    function closeWin() {
        // api.execScript({
        //     name: 'index',
        //     script: 'reloadIndex();'
        // });
        api.closeFrame();

    }

    function click_in(index) {
      api.showProgress({
          title: '努力加载中...',
          modal: false
      });
        api.openWin({
            name: 'jianlihead',
            url: './jianlihead.html',
            // scaleEnabled: true,
            reload: true,
            pageParam: {
                id: index
            },
            // delay: 500
        });

    }

    apiready = function() {

        var color = $api.getStorage('color');
        $(".theme").attr("href", color);
        var sql = api.pageParam.sql;
        // console.log(sql);
        var topbar = api.pageParam.title;
        $('#topbar').text(topbar);
        //是否党员字段
        var d = api.pageParam.d;
        var db = api.require('CPDB');
        db.selectSql({
            name: 'data',
            sql: sql
        }, function(ret, err) {
            if (ret.status != false) {
                api.hideProgress();
                var data = ret.data;
                if (d == 1 || d == 2) {
                    data = isDY(ret.data, d);
                }
                if (ret.data == '') {
                    data = '0';
                } else {
                    if (data) {
                        var count = '符合条件记录数(' + data.length + ')条'
                        $('#count').html(count);
                    }
                }
                var dotFn = doT.template(template.innerHTML);
                var html = dotFn(data);
                var list = $api.byId('list');
                $api.html(list, html);
        
                setTimeout(function() {
                  echoInit();
                }, 1);
            } else {
                alert(JSON.stringify(err));
            }
        });
    }

    function isDY(data, d) {
        var dy = new Array();
        var fdy = new Array();
        for (var i = 0; i < data.length; i++) {
            var time = data[i].I07.substring(0, 4);
            var ival = parseInt(time);
            if (!isNaN(ival)) {
                dy.push(data[i]);

            } else {
                fdy.push(data[i]);

            }
        }
        if (d == 1) {
            return dy;
        } else {
            return fdy;
        }
    }




</script>
